<?php

namespace Biz\model\brandAccount;

use Doraemon\pockets\datebase\BaseDbModel;

class BrandAccountLog extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    const _TABLE_NAME = 'brand_account_log';

    const OPERATE_NEW_ACCOUNT = 'new_account_info';//新加品牌账户信息
    const OPERATE_USER_EDIT_AUTH = 'user_edit_auth';//用户编辑/添加认证信息

    const OPERATE_EDIT_ACCOUNT = 'edit_account_info';//编辑账户信息
    const OPERATE_EDIT_ACCOUNT_AUTH = 'edit_account_auth';//编辑账户当前认证信息
    const OPERATE_EDIT_ACCOUNT_SHOP = 'edit_account_shop';//编辑账户当前店铺信息
    const OPERATE_AUDIT_ACCOUNT_AUTH = 'audit_account_auth';//审核账户认证信息
    const OPERATE_DEL_ACCOUNT = 'del_account_info';//删除账户信息
    const OPERATE_DEL_AUTH = 'del_auth_info';//删除认证信息
    const OPERATE_OPEN_SHOP_ACCOUNT = 'open_shop_account';//开通店铺账户

    public static function getAllByWhere($where = [], $files = '*')
    {
        $data = self::select($files, $where);
        return $data;
    }

    public static function getOneByWhere($where = [], $files = '*')
    {
        $data = self::get($files, $where);
        return $data;
    }

    public static function insertData($data)
    {
        if (!isset($data['add_time'])) {
            $data['add_time'] = date('Y-m-d H:i:s');
        }
        if (!isset($data['edit_time'])) {
            $data['edit_time'] = date('Y-m-d H:i:s');
        }
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }

    public static function updateData($data, $where)
    {
        if (!isset($data['edit_time'])) {
            $data['edit_time'] = date('Y-m-d H:i:s');
        }
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

}